<template>
	<view>
		<view class="bodys">
			<rich-text :nodes="formatRichText(info)"></rich-text>
			</view>
	</view>
</template>

<script>
	
	import {curl} from 'common/api.js';
	
	export default {
		data() {
			return {
				info:'操作指南'
			}
		},
		onLoad(ret) {
			var that=this;
			curl('index/getmessagebyid', {id:ret.id}).then((res) => {
				console.log('详情',res.data);
				that.info=res.data.content
			});
		},
		methods: {
			formatRichText(html) {
				let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
					console.log(match.search(/style=/gi));
					if (match.search(/style=/gi) == -1) {
						match = match.replace(/\<img/gi, '<img style=""');
					}
					return match;
				});
					
				newContent = newContent.replace(/style="/gi, '$& max-width:100% !important; ');
				newContent = newContent.replace(/<br[^>]*\/>/gi, '');
				return newContent;
			},
		}
	}
</script>

<style>
	.bodys{
		width: 710rpx;margin: auto;
	}
</style>
